using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Boomlagoon.JSON;

public class EntityStateParser {
	public static void parseEntityState (JSONObject entityStateJsonObj , EntityState entityState)
	{
		entityState.Name = entityStateJsonObj.GetString("name");
		entityState.CommanderPlayerStateId = entityStateJsonObj.GetString("commanderPlayerStateId");
		entityState.Hp = (int)entityStateJsonObj.GetNumber("hp");
		entityState.X = (float)entityStateJsonObj.GetNumber("x");
		entityState.Y = (float)entityStateJsonObj.GetNumber("y");
		entityState.XGoal = (float)entityStateJsonObj.GetNumber("xGoal");
		entityState.YGoal = (float)entityStateJsonObj.GetNumber("yGoal");

		JSONObject quantifiablesJsonObj = entityStateJsonObj.GetObject("quantifiables");
		foreach (KeyValuePair<string,JSONValue> pair in quantifiablesJsonObj)
		{
			Quantifiable quantifiable = (Quantifiable)System.Enum.Parse(typeof(Quantifiable) , pair.Key);
			int quantity = (int)pair.Value.Number;
			entityState.Quantifiables.Add(quantifiable , quantity);
		}
	}
}
